package version1;
import condorAPI.*;

public class JobHandler{
  
  public static void main(String [] args) throws CondorException{
	// create a Condor object
	Condor condor = new Condor();

	// create a JobDescription object using exsiting file 
	// 'test.submit'
	JobDescription jd = new JobDescription("submit");

	// create a handler as inline object.
	Handler handler = new Handler(){
	  public void handle(Event e){
		System.out.println("got event: " + e);
		System.out.println(e.getJob());
	  }
	};

	jd.setHandler(EventType.SUBMIT, handler);
	jd.setHandler(EventType.EXECUTE, handler);
	jd.setHandler(EventType.JOB_TERMINATED, handler);
	jd.setHandler(EventType.JOB_EVICTED, handler);
	jd.setHandler(EventType.JOB_ABORTED, handler);

	// submit the job and get Cluster
	Cluster c = condor.submit(jd);

	System.out.println("submitted " + c);
  }
}